package Math类;

public class RandomInt {
	
	/**
	 * 随机输出ch1--ch2的int数据
	 * @param ch1
	 * @param ch2
	 * @return
	 */
	public static int randomInt(int ch1,int ch2){
		
		return ch1+((int)(Math.random()*(ch2-ch1)));
	}
	/**
	 * 随机输出ch1--ch2的double数据
	 * @param ch1
	 * @param ch2
	 * @return
	 */
	public static double randomDouble(double ch1,double ch2){
		
		return ch1+(Math.random()*(ch2-ch1));
	}
	/**
	 * 随机输出ch1--ch2的char数据
	 * @param ch1
	 * @param ch2
	 * @return
	 */
	public static char randomChar(int ch1,int ch2){
		
		return (char)(ch1+(Math.random()*(ch2-ch1 +1)));
	}
	
	/**
	 * 反向倒置 整数
	 * @param number
	 * @return
	 */
	public static int reverse(int number){
		int sum = 0;
		while(number > 0){
			int temp = number % 10; //123  3
			sum = sum * 10 + temp; //0 * 10 +3
			number = number / 10; //123 12
		}
		return sum;
	}
	
	/**
	 * 判断是否是回文数
	 * @param number
	 * @return
	 */
	public static boolean isPalindrome(int number){
		if(number == reverse(number))
			return true;
		else
			return false;
	}
	
	/**
	 * 排序
	 * @param num1
	 * @param num2
	 * @param num3
	 */
	public static void displaySortedNumber(double num1,double num2,double num3){
		double []  nums= {num1,num2,num3};
		double temp = 0.0;
		for (int j = 1; j < nums.length; j++) {
			for (int i = 0; i < nums.length-j; i++) {
				if(nums[i] > nums[i+1]){
					 temp = nums[i+1];
					 nums[i+1] = nums[i];                                                                               
					 nums[i] = temp;
				}
			}
		}
		for (int i = 0; i < nums.length; i++) {
			System.out.println(nums[i]);
		}
	}
	
	public static void displayPattern(int n){
		for (int j = 1; j <= n; j++) {
			for (int i = j; i < n; i++) {
				System.out.print(" ");
			}
			System.out.println(j);
		}
			
	}
	
	public static void main(String[] args) {
//		int i = randomInt(0,999);
//		double d = randomDouble(5.5,55.55);
//		char c = randomChar(97,122);
//		int c = reverse(1234567);
//		boolean b = isPalindrome(222222);
//		displaySortedNumber(5,3,4);
//		System.out.println(d);
		displayPattern(3);
	}
}
